import React, { useState, useEffect } from 'react';
import { Button, Divider } from 'antd';

// 代表集合了componentDidMount生命周期函数，且当count发生变化时，才会触发componentDidUpdate生命周期函数
export default () => {

    const [count, setCount] = useState(0);

    console.log(1);

    useEffect(() => {
        console.log(2);
    }, [count]);

    console.log(3);

    // 树苗增加
    const handleIn = () => {
        setCount(count + 1);
        console.log(4);
    }

    return (
        <div>
            {console.log(5)}
            {`当前的树苗数量：${count}`}
            <Divider />
            <Button type='primary' onClick={handleIn}>树苗+1</Button>
        </div>
    )
}


